home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / p / portfoli / pglib / pgsample.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-30  |  2.2 KB  |  113 lines

  1. /* PGSAMPLE.C - Program to test PGLIB */
  2. #include    <stdio.h>
  3. #include    <dos.h>
  4. #include    "pglib.h"
  5.  
  6. char    fuji[1920];
  7. char    portf[1920];
  8.  
  9. main()
  10. {
  11.     int i, j, result;
  12.  
  13.     /* initialize the graphics routines */
  14.     result = PG_Init();
  15.     if(result == 0)
  16.     {
  17.         puts("This is not an Atari Portfolio!");
  18.         exit(1);
  19.     }
  20.  
  21.     /* put Portfolio into graphics mode */
  22.     PG_GoGraphic();
  23.  
  24.     /* Plot some pixels */
  25.     PlotSpiral();
  26.  
  27.     /* wait for a bit */
  28.    for(j = 0; j < 30000; j++);
  29.  
  30.     /* draw some lines */
  31.     PG_Line(0,0,239,63);
  32.     PG_Line(0,63,239,0);
  33.  
  34.     /* wait for a bit */
  35.    for(j = 0; j < 30000; j++);
  36.  
  37.     /* load in a picture */
  38.     PG_Show("portf.pgc");
  39.    PG_Move((char far *)portf, SCREEN);
  40.     PG_Load("fuji.pgc", (char far *)fuji);
  41.  
  42.     /* wait for a bit */
  43.     for(j = 0; j < 30000; j++);
  44.  
  45.     /* clear the screen */
  46.     PG_ClearScreen();
  47.  
  48.     for(i = 0; i < 10; i++)
  49.     {
  50.         PG_Move(SCREEN, (char far *)fuji);
  51.         PG_Move(SCREEN, (char far *)portf);
  52.     }
  53.  
  54.     /* save screen to disk as PGC file */
  55.     result = PG_Save("newportf.pgc", SCREEN);
  56.     if(result != OK)
  57.     {
  58.         PG_GoText();
  59.         if(result == BADOPEN) puts("Error opening file");
  60.         else puts("Error writing file");
  61.         exit(1);
  62.     }
  63.  
  64.     /* save buffer to disk as PGC file */
  65.     result = PG_Save("newfuji.pgc", (char far *)fuji);
  66.     if(result != OK)
  67.     {
  68.         PG_GoText();
  69.         if(result == BADOPEN) puts("Error opening file");
  70.         else puts("Error writing file");
  71.         exit(1);
  72.     }
  73.  
  74.     /* return to text mode */
  75.     PG_GoText();
  76. }
  77.  
  78. PlotSpiral()
  79. {
  80.    int x, y;
  81.    int x1 = 0;
  82.    int x2 = 239;
  83.    int y1 = 0;
  84.    int y2 = 63;
  85.  
  86.     /* plot in quiet mode */
  87.    while (y1 < 32)
  88.    {
  89.       for (x = x1; x <= x2; x++) PG_QPlot(x, y1, BLACK);
  90.       for (y = y1; y <= y2; y++) PG_QPlot(x2, y, BLACK);
  91.       for (x = x2; x >= x1; x--) PG_QPlot(x, y2, BLACK);
  92.       for (y = y2; y >= y1; y--) PG_QPlot(x1, y, BLACK);
  93.       x2 -= 2; y2 -= 2; y1 += 2; x1 += 2;
  94.     }
  95.  
  96.     /* now show it */
  97.     PG_Refresh();
  98.  
  99.     /* Plot in normal mode */
  100.     while(y1 > 0)
  101.    {
  102.       x2 += 2; y2 += 2; y1 -= 2; x1 -= 2;
  103.       for (x = x1; x <= x2; x++) PG_Plot(x, y1, WHITE);
  104.       for (y = y1; y <= y2; y++) PG_Plot(x2, y, WHITE);
  105.       for (x = x2; x >= x1; x--) PG_Plot(x, y2, WHITE);
  106.       for (y = y2; y >= y1; y--) PG_Plot(x1, y, WHITE);
  107.    }
  108. }
  109.  
  110.  
  111.  
  112.  
  113.